package com.hub.nio.socket.bio;


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * @ author 令狐冲
 * @ date & time 2025/1/23 16:33
 */
public class BIOClient {

    private static final BufferedReader KEYBOARD_INPUT = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) {
        try {
            Socket socket = new Socket("localhost", 9999);
            boolean flag = true;
            BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(socket.getOutputStream());
            while (flag) {
                String str = KEYBOARD_INPUT.readLine();
                bufferedOutputStream.write(str.getBytes());
                bufferedOutputStream.flush();
            }
            socket.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
